package com.hurl.library.spider;

import java.util.ArrayList;
import java.util.List;

public class StringRule implements UrlRule{
	private List<String> valueList = new ArrayList<String>();
	private int nextIndex;
	private String previous;
	
	public StringRule(){
		beforeFirst();
	}
	
	public void addValue(String value){
		valueList.add(value);
	}
	public void clearValue(){
		valueList.clear();
	}
	public List<String> getValueList(){
		return valueList;
	}
	@Override
	public boolean hasNext() {
		return nextIndex<valueList.size();
	}
	@Override
	public String next() {
		if(!hasNext()){
			return null;
		}
		
		String res = valueList.get(nextIndex);
		this.previous=res;
		nextIndex++;
		return res;
	}
	@Override
	public void beforeFirst() {
		previous = null;
		nextIndex = 0;
	}

	@Override
	public String previous() {
		return previous;
	}
}
